<script setup>


import {ref, watchEffect} from "vue";

let count = ref(0);
let elem = ref();

//刚开始触发一次，而后所依赖的数据发生改变，就会再次触发
//触发时机是数据响应后，dom更新前
watchEffect(()=>{
  console.log(count.value)
  if(elem.value)
    console.log(elem.value.innerHTML)
},{
  //pre
  //post dom更新后触发
  flush:'post'
})

setTimeout(()=>{
  count.value +=1 ;
},2000)

</script>

<template>
  <div ref="elem">06_composition_api_watch_watcheffect.vue</div>
</template>

<style scoped>

</style>